<?php
/* OpenBIBLIO -- A library administration web interface
 * Copyright (C) 2002-2005 Frederic Descamps <lefred@tiscali.be>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
include_once("includes/functions.inc");
include_once("includes/db.inc");

session_start();
include_once("includes/session.inc");

$login=$_POST['login'];
$pwd=$_POST['pwd'];
$user=$_POST['user'];


ControleAcces("admin.php",$login,$pwd,$user_id,session_id());

if($user_id)
{

if ($_POST['action']) { $action = $_POST['action']; }
else 
{
   if ($_GET['action']) { $action = $_GET['action']; }
}
if ($_POST['type']) { $type = $_POST['type']; }
else 
{
   if ($_GET['type']) { $type = $_GET['type']; }
}
if ($_GET['menu']) { $type = $_GET['menu']; }

$result = biblio_db_query("SELECT login FROM admin WHERE id = $user_id" ,$db);
$myrow = biblio_db_fetch_array($result);
$user = $myrow['login'] ;
   
$title = "Administration";
include("includes/header.inc");


if (!$action)
{
 $requete = "SELECT * FROM admin WHERE login = '$user'";
 $resultat = biblio_db_query($requete);
 while ($row=biblio_db_fetch_array( $resultat ))
 {

   ?>
   <CENTER>
   <TABLE CELLSPACING=7>
   <TR><th>
   <?php echo _("Ajout"); ?>
   </th><th>
   <?php echo _("Modification"); ?> 
   </th><th>
   <?php echo _("Effacement"); ?>
   </th>
   <TR><TD>
   <A HREF="admin.php?action=add&type=admin">
   <?php echo _("Ajouter un administrateur"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=admin">
   <?php echo _("Modifier un administrateur"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=del&type=admin">
   <?php echo _("Effacer un administrateur"); ?>
   </A>
   </TD><TR><TD>
   <A HREF="admin.php?action=add&type=eleve">
   <?php echo _("Ajouter un &eacute;l&egrave;ve"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=eleve">
   <?php echo _("Modifier un &eacute;l&egrave;ve"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=del&type=eleve">
   <?php echo _("Effacer un &eacute;l&egrave;ve"); ?>
   </A>
   </TD><TR><TD>
   <A HREF="admin.php?action=add&type=classe">
   <?php echo _("Ajouter une classe"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=classe">
   <?php echo _("Modifier une classe"); ?>
   </A>
   </TD><TR><TD>
   </TD><TR><TD>
   <A HREF="admin.php?action=add&type=livre">
   <?php echo _("Ajouter un livre"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=livre">
   <?php echo _("Modifier un livre"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=del&type=livre">
   <?php echo _("Effacer un livre"); ?>
   </A>
   </TD><TR><TD>
   <A HREF="admin.php?action=add&type=genre">
   <?php echo _("Ajouter un genre"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=genre">
   <?php echo _("Modifier un genre"); ?>
   </A>
   </TD>
   <TR><TD>
   <A HREF="admin.php?action=add&type=status">
   <?php echo _("Ajouter un &eacute;tat"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=status">
   <?php echo _("Modifier un &eacute;tat"); ?>
   </A>
   </TD>
   <TR><TD>
   <A HREF="admin.php?action=add&type=location">
   <?php echo _("Ajouter un emplacement"); ?>
   </A>
   </TD><TD>
   <A HREF="admin.php?action=mod&type=location">
   <?php echo _("Modifier un emplacement"); ?>
   </A>
   </TD>
   </TABLE>
   <TABLE CELLSPACING=7>
   <TR><th>
   <?php echo _("Statistiques"); ?>
   </th><th>
   <?php echo _("Listing"); ?>
   </th><th>
   <?php echo _("Historique"); ?>
   </th>
   <TR><TD>
   <A HREF="statsbook.php">
   <?php echo _("Livres"); ?>
   </A>
   </TD>
   <TD>
   <A HREF="calendrier.php">
   <?php echo _("module calendrier"); ?>
   </A>
   </TD>
   <TD ALIGN=RIGHT>
   <A HREF="histobook.php">
   <?php echo _("Livres"); ?>
   </A>
   </TD>
   <TR><TD>
   <A HREF="statsel.php">
   <?php echo _("El&egrave;ves"); ?>
   </A>
   </TD>
   <TD>
   <A HREF="classeslist.php">
   <?php echo _("listing des classes"); ?>
   </A>
   </TD>
   <TD ALIGN=RIGHT>
   <A HREF="histoel.php">
   <?php echo _("El&egrave;ves"); ?>
   </A>
   </TD>
   <TR><TD>
   <A HREF="statclas.php">
   <?php echo _("Classes"); ?>
   </A>
   </TD>
   <TD>
   <A HREF="pretlist.php">
   <?php echo _("emprunts"); ?>
   </A>
   </TD>
   <TR><TD>
   <A HREF="graphs.php">
   <?php echo _("Graphiques"); ?>
   </A>
   </TD><TD>
   <A HREF="retourlist.php">
   <?php echo _("retours du jour"); ?>
   </A>
   </TD>
   </tr>
   <tr></tr>
   <tr><td colspan=3 align=center><a href="admin.php?action=config">
   <?php echo _("Configuration d'OpenBiblio"); ?>
   </td></tr>
   </TABLE>
   </CENTER>
   <BR><BR>
   <div>
   <span id=left-text>
   <A HREF="admin.php?action=logout">
   <?php echo _("d&eacute;connexion"); ?>
   </A><BR>
   <A HREF="index.php">
   <?php echo _("retour menu principal"); ?>
   </A></span> 
   <span id=right-text>   <A HREF="deltemp.php">
   <?php echo _("effacer les livres temporaires"); ?>
   </A></span>
   </div>
   <br>
   <?php
 }
}

switch($action)
{
    case logout:   session_unregister("userIDInternaute");
                   session_destroy(); 
                   $session_id = session_id();
                   $result = biblio_db_query("DELETE FROM session where idSession like '%$session_id%'" ,$db);
		   echo "<br><br><div id=message>";
                   echo _("vous &ecirc;tes d&eacute;connect&eacute;<BR><BR>");
                   echo "<A HREF=\"index.php\">";
		   echo _("retour menu principal");
		   echo "</A>";
		   echo "</div>";
                   break;
                
    case add:
                switch($type)
                {
                 case classe:
                        include("classeadd.php");
                        break;
                 case admin:
                        include("adminadd.php");
                        break;
                 case eleve:
                        include("eleveadd.php");
                        break;
                 case livre:
                        include("livreadd.php");
                        break;
                 case genre:
                        include("genreadd.php");
                        break;
                 case status:
                        include("etatadd.php");
                        break;
                 case location:
                        include("locationadd.php");
                        break;
                }
                break;
    
    case mod:
                switch($type)
                {
                 case classe:
                        include("classemod.php");
                        break;
                 case admin:
                        include("adminmod.php");
                        break;
                 case eleve:
                        include("elevemod.php");
                        break;
                 case livre:
                        include("livremod.php");
                        break;
                 case genre:
                 	include("genremod.php");
                        break;
                 case status:                 
                        include("etatmod.php");
                        break;
                 case location:
                        include("locationmod.php");
                        break;
                }
                break;
    case del:
                switch($type)
                {
                 case admin:
                        include("admindel.php");
                        break;
                 case eleve:
                        include("elevedel.php");
                        break;
                 case livre:
                        include("livredel.php");
                        break;
                 case genre:
                 
                        break;
                 case status:
                 
                        break;
                 case location:
                 
                        break;
                 case classe:
                 
                        break;
                }
                break;
    case config:
            	include("config.php");
		break;
 }
}
include_once("includes/footer.inc");
?>
